package com;

/**
 * @author qqq
 * @version 1.0
 * @date $(DATE)$(TIME)
 * @description
 */
public class Test1 {
    public static void main1(String[] args) {
        Book[] all = new Book[3];
        all[0] = new Book(01,"《明朝那点事》","黎奇 ",100,50 ,70,"static/img/1.jpg");
        all[1] = new Book(02,"《宋朝那点事》","郭凯文",80,10 ,80,"static/img/1.jpg");
        all[2] = new Book(03,"《唐朝那点事》","胡安应",200,100,120,"static/img/1.jpg");
        System.out.println("排序前:");
        System.out.println("编号\t书名\t\t\t作者\t\t价格\t\t销量\t库存\t图片");
        for (int i = 0; i < all.length; i++) {
            System.out.println(all[i].getInfo());
        }
        for (int i = 0; i < all.length; i++) {
            for (int j = 0; j < all.length - 1; j++) {
                if (all[j].getSales() < all[j + 1].getSales()) {
                    Book sales = all[j];
                    all[j] = all[j + 1];
                    all[j + 1] = sales;
                }
            }
        }
        System.out.println("排序后:");
        System.out.println("编号\t书名\t\t\t作者\t\t价格\t\t销量\t库存\t图片");
        for (int i = 0; i < all.length; i++) {
            System.out.println(all[i].getInfo());
        }
    }

    public static void main2(String[] args) {
        Rectangle juxing = new Rectangle();
        juxing.setChang(5);
        juxing.setKuan(4);
        System.out.println("长：" + juxing.getChang());
        System.out.println("宽：" + juxing.getKuan());
        System.out.println("面积：" + juxing.getArea());
        System.out.println("周长：" + juxing.getPerimeter());
    }

    public static void main(String[] args) {
        Rectangle [] arr = new Rectangle[5];
        for (int i = 0; i < arr.length; i++) {
            double chang = Math.random()*9+1;
            double kuan = Math.random()*9+1;
            arr[i] = new Rectangle(chang,kuan);
        }
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i].getInfo());
        }
        for (int i = 1; i < arr.length; i++) {
            for (int j = 1; j < arr.length-i-1; j++) {
                if(arr[j].getArea()>arr[j+1].getArea()){
                    Rectangle temp = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = temp;
                }
            }
        }
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i].getInfo());
        }

    }
}
